fix mkshort unique (#1168)
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Fri, 1 Sep 2023 17:00:45 +0000 (11:00 -0600)
committerGitHub <noreply@github.com>
Fri, 1 Sep 2023 17:00:45 +0000 (11:00 -0600)
commitd8b5e673126ccb7ae7851b2851f2f0fd75099a59
tree8edf37b7c1890ce9ae0b429e75928599cf1d23b9
parent8b3e3743f007e5040f894bf5493b1e6c3a0c5847
fix mkshort unique (#1168)

* fix mkshort unique.

1. we were off by one when deciding if we could just concatentate
the generated suffix to the name, failing to use the last available
character.
2. when attempting to copy the generated suffix to a presumably
shortened name, and the generated suffix was longer than the name,
the target of the copy was outside the name buffer.  In the common
case that the rank of size_t was greater than the rank of int, the
target was well beyond the end of name, not before as one would expect
with signed arithmetic.

With the new algorithm when the target length is insufficient to
fit both the name and the suffix we will only truncate the name as
required to fit the truncated name and the complete suffix in the
target length(as opposed to the original length of the name).
We fatal if this is not possible.

Add a test case to exercise the make unique code.

* fix reference mode.

* add notes for future enhancements

* fix testcase cut and paste booboo

* refactor mkshort input from char* to QByteArray.
defs.h
garmin.cc
mkshort.cc
reference/mkshort.csv [new file with mode: 0644]
reference/mkshort.style [new file with mode: 0644]
reference/mkshort3.log [new file with mode: 0644]
reference/mkshort4.csv [new file with mode: 0644]
reference/mkshort5.csv [new file with mode: 0644]
reference/mkshort6.csv [new file with mode: 0644]
testo.d/mkshort.test [new file with mode: 0644]